#include <iostream>

using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

ListNode* removeNthFromEnd(ListNode* head, int n) {
    int size = 0;
    ListNode* p = head;
    while(p->next){
        size++;
        p = p->next;
    }
    size++;
    p = head;
    int cnt = 0;
    while(cnt != size-n-1){
        p = p->next;
        cnt++;
    }
    ListNode* q=p->next;
    p->next = q->next;
    delete q;
    return head;

}

int main() {
    cout << "hello world" << endl;
    return 0;
}